//@author A0091838U
//@The class define the Patterns of CrossOff Support 24 Time Hours Zone Format
package crossoff.datetime;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Time24HoursValidator {

	private Pattern pattern;
	private Pattern pattern1;
	private Matcher matcher;

	private static final String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
	private static final String TIME24HOURS_PATTERN1 = "([01][0-9]|2[0-3])([0-5][0-9])";

	public Time24HoursValidator() {
		pattern = Pattern.compile(TIME24HOURS_PATTERN);
		pattern1 = Pattern.compile(TIME24HOURS_PATTERN1);
	}

	/**
	 * Validate time in 24 hours format with regular expression
	 * 
	 * @param time
	 *            time address for validation
	 * @return true valid time format, false invalid time format
	 */
	public boolean validate(final String time) {
		matcher = pattern.matcher(time);
		return matcher.matches();
	}

	public boolean validate1(final String time) {
		matcher = pattern1.matcher(time);
		return matcher.matches();
	}

	public Pattern getPattern() {
		return pattern;
	}

	public Pattern getPattern1() {
		return pattern1;
	}

}